#pragma once

#include "BaseInc.h"
#include "CPaint.h"
#include "CWindowBuffer.h"

class CRender : public IRender, public ITextEngine
{
public:
	CRender(HDC hdcPaint);
	~CRender();

	IBuffer * CreateBuffer();
	IBuffer * CreateBuffer(int_32 iWidth, int_32 iHeight);

	void RenderBuffer(
		int_32 iDstX, int_32 iDstY, 
		const IBuffer * pSrc, int_32 iSrcX, int_32 iSrcY, 
		int_32 iWidth, int_32 iHeight) const;

	void SetRenderBuffer(IBuffer * pBuffer);
	void SetBufferSize(IBuffer * pBuffer, int_32 iWidth, int_32 iHeight);

	void RenderControl(IControl * pControl, const CPointInt32 & posOrign, const CRectInt32 & rect);

	void MeasureString(const char_16 * szText, int_32 iLen, const FontFormat & format, CSizeInt32 & siMeasure);
public:
	void BitBltTo(HDC hdc, int_32 iX, int_32 iY, int_32 iWidth, int_32 iHeight);

private:
	void RenderContainer(IContainer * pContainer, const CPointInt32 & posOrign, const CRectInt32 & rect);
private:
	HDC m_hdcPaint;
	HDC m_hdcCtrl;
	CWindowBuffer m_buffer;
};
